﻿using NHibernate.Mapping.ByCode;
using DAEProde.Domain;

namespace DAEProde.NHibernateProvider.Overrides
{
    public class TournamentOverride : IOverride
    {
        public void Override(ModelMapper mapper)
        {
            // Define el lado de Torneo de la relacion many-to-many con Equipo
            mapper.Class<Tournament>(map =>
                map.Bag(x => x.Teams,
                    bag =>
                    {
                        bag.Key(key => key.Column("TournamentFk"));
                        bag.Table("Tournament_Team");
                        bag.Cascade(Cascade.None);
                    },
                    collectionRelation =>
                        collectionRelation.ManyToMany(m => m.Column("TeamFk"))));
        }
    }
}
